<template>
    <div class="box">
        <header class="header">user header</header>
        <div class="content">
            <van-button type="warning" @click="loginOut">退出登录</van-button>
            <p>{{ username }}</p>
        </div>
    </div>
</template>
<script>
import { showDialog } from 'vant';

export default {
    data() {
        return {
            username: localStorage.getItem('username')
        }
    },
    methods: {
        loginOut() {
            showDialog({
                message: '你确认退出登录吗？',
            }).then(() => {
                // on close
                localStorage.removeItem('token');
                this.$router.push('/login');
            });
        }
    }
}
</script>